RAIS  3.2
C:/Projekte/RAIS/Specific Masks/SpecificReportViewer.aspx.cs
Go to the documentation of this file.
00001 using System;
00002 using System.Collections;
00003 using System.Collections.Generic;
00004 using System.Configuration;
00005 using System.Data;
00006 using System.Linq;
00007 using System.Web;
00008 using System.Web.Security;
00009 using System.Web.UI;
00010 using System.Web.UI.HtmlControls;
00011 using System.Web.UI.WebControls;
00012 using System.Web.UI.WebControls.WebParts;
00013 using System.Xml.Linq;
00014 using Microsoft.Reporting.WebForms;
00015 using System.IO;
00016 using RAIS.UI.Common;
00017 
00018 namespace RAIS.UI.SpecificMasks
00019 {
00020     public partial class SpecificReportViewer : System.Web.UI.Page
00021     {
00022         #region PROPERTIES
00023         protected Dictionary<string, DataTable> SpecificReportData
00024         {
00025             get
00026             {
00027                 if (Session["SpecificReportData"] != null)
00028                     return (Dictionary<string, DataTable>)Session["SpecificReportData"];
00029                 else return null;
00030             }
00031         }
00032         #endregion
00033 
00034         #region EVENTS
00035         protected void Page_Load(object sender, EventArgs e)
00036         {
00037             if (!((bool)Session["HasSpecificSubreports"]))
00038             {
00039                 DataTable reportTable = (DataTable)Session["SpecificReportDataTable"];
00040                 ReportViewerMain.LocalReport.DataSources.Add(new ReportDataSource("ReportDataSet", reportTable));
00041                 StringReader reader = new StringReader(Session["SpecificReportDefinition"].ToString());
00042                 ReportViewerMain.LocalReport.LoadReportDefinition(reader);
00043             }
00044             else
00045             {
00046                 // Process subreports
00047                 DataTable reportDataSource = SpecificReportData.ElementAt(0).Value;
00048                 reportDataSource.TableName = "ReportDataTable";
00049                 ReportViewerMain.LocalReport.DataSources.Add(new ReportDataSource("ReportDataSet", reportDataSource));
00050                 string mainReport = SpecificReportData.ElementAt(0).Key;
00051                 int mainReportID = SpecificReportManagement.GetSpecificReportIdByName(mainReport);
00052                 string reportDefinition = SpecificReportManagement.GetSpecificReportDefinition(mainReportID);
00053                 StringReader reader = new StringReader(reportDefinition);
00054                 ReportViewerMain.LocalReport.LoadReportDefinition(reader);
00055                 ReportViewerMain.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(onSubreportProcessing);
00056 
00057                 foreach (KeyValuePair<string, DataTable> pair in SpecificReportData)
00058                 {
00059                     if (!pair.Key.Equals(SpecificReportData.ElementAt(0).Key))
00060                     {
00061                         string subreportName = pair.Key;
00062                         string subreportDefinition = SpecificReportManagement.GetSpecificReportDefinition(SpecificReportManagement.GetSpecificReportIdByName(subreportName));
00063                         reader = new StringReader(subreportDefinition);
00064                         ReportViewerMain.LocalReport.LoadSubreportDefinition(subreportName, reader);
00065                     }
00066                 }
00067             }
00068 
00069             ReportViewerMain.LocalReport.EnableExternalImages = true;
00070             ReportViewerMain.LocalReport.Refresh();
00071             Session["HasSpecificSubreports"] = false;
00072         }
00073 
00074         private void onSubreportProcessing(object sender, SubreportProcessingEventArgs e)
00075         {
00076             DataTable reportDataSource = (DataTable)this.SpecificReportData[e.ReportPath];
00077             reportDataSource.TableName = "ReportDataTable";
00078             e.DataSources.Add(new ReportDataSource("ReportDataSet", reportDataSource));
00079         }
00080         #endregion
00081     }
00082 }